package cn.iocoder.yudao.module.ai.dal.mysql.modelfactoryparam;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.ai.dal.dataobject.busimodelparam.BusiModelParamDO;
import cn.iocoder.yudao.module.ai.dal.dataobject.modelfactoryparam.ModelFactoryParamDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.ai.controller.admin.modelfactoryparam.vo.*;

/**
 * 模型参数 Mapper
 *
 * @author 侯俊青
 */
@Mapper
public interface ModelFactoryParamMapper extends BaseMapperX<ModelFactoryParamDO> {

    default PageResult<ModelFactoryParamDO> selectPage(ModelFactoryParamPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ModelFactoryParamDO>()
                .eqIfPresent(ModelFactoryParamDO::getBusiModelId, reqVO.getBusiModelId())
                .likeIfPresent(ModelFactoryParamDO::getParamName, reqVO.getParamName())
                .eqIfPresent(ModelFactoryParamDO::getParamDesc, reqVO.getParamDesc())
                .eqIfPresent(ModelFactoryParamDO::getParamType, reqVO.getParamType())
                .eqIfPresent(ModelFactoryParamDO::getNullable, reqVO.getNullable())
                .eqIfPresent(ModelFactoryParamDO::getDefaultValue, reqVO.getDefaultValue())
                .eqIfPresent(ModelFactoryParamDO::getParamInfo, reqVO.getParamInfo())
                .betweenIfPresent(ModelFactoryParamDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ModelFactoryParamDO::getSourceFile, reqVO.getSourceFile())
                .orderByDesc(ModelFactoryParamDO::getId));
    }

    default List<ModelFactoryParamDO> selectParams(Integer modelId, String sourceFile) {
        return selectList(new LambdaQueryWrapperX<ModelFactoryParamDO>()
                .eqIfPresent(ModelFactoryParamDO::getBusiModelId, modelId)
                .eqIfPresent(ModelFactoryParamDO::getSourceFile, sourceFile));

    }
}